
var dcwdArray = [];
//调查文档查询
function initDcwdTable(){
	$("#dcwdTable").datagrid({
		url:"",
		striped : true,
		pageSize : 10,
		height : 315,
		nowrap : false,
		columns : [[ {
					field : '0_yjdc06010',
					title : '工程文档类别',
					width : 80,
					align : 'center',
					editor : 'text',
					formatter : function(value, rec, rowIndex) {// value id rec
						// 该对象
						
						var name = rec[0].yjdc06010.substring(0,2);
						var showStr = "";
						if(name=="YD")
							showStr = "应急调查";
						if(name=="YK")
							showStr = "快报";
						if(name=="DJ")
							showStr = "简报";
						var resutsHTML = "";
						var resutsHTML = "<div style='align:center;'>"
								+ showStr
								+"</div>";
						return resutsHTML;
					}
				},{
					field : '1_jbqk0110',
					title : '灾害点名称',
					width : 150,
					align : 'center',
					editor : 'text'
				},{
					field : '0_jbqk0102',
					title : '灾害点标识',
					width : 150,
					align : 'center',
					editor : 'text',
					formatter : function(value, rec, rowIndex) {// value id rec
						// 该对象
						
						var name = rec[0].jbqk0102;
						var showStr = top.getOperTypeZhdByCode(name);
						var resutsHTML = "";
						var resutsHTML = "<div style='align:center;'>"
								+ showStr
								+"</div>";
						return resutsHTML;
					}
				},{
					field : '0_yjdc06020',
					title : '提交报告单位',
					width : 120,
					align : 'center',
					editor : 'text'
				},{
					field : '0_yjdc06030',
					title : '报告主编',
					width : 60,
					align : 'center',
					editor : 'text'
				},
				/*
				 * {
					field : 'yjdc06040',
					title : '主编专业职称',
					width : 80,
					align : 'center',
					editor : 'text'
				},
				{
					field : 'yjdc06060',
					title : '报告内容摘要',
					width : 120,
					align : 'center',
					editor : 'text'
				},*/
				{
					field : '0_yjdc06080',
					title : '报告提交时间',
					width : 160,
					align : 'center',
					editor : 'text'
				},{
					field : 'oper',
					title : '操作',
					width : 120,
					align : 'center',
					formatter : function(value, rec, rowIndex) {// value id rec
						// 该对象
						//curRecObj = rec;
						dcwdArray.push(rec[0]);
						var num = dcwdArray.length-1;
						var resutsHTML = "";
						var resutsHTML = "<div style='align:center;'>"
								+ "<a name='showDetails' style='padding:5px;cursor:pointer;text-decoration: underline;' onclick='downloadDCWDPdf(\""
								+ num
								+ "\",false)'>下载报告</a>"
								+"<a name='showDetails' style='padding:5px;cursor:pointer;text-decoration: underline;' onclick='showXianqingDcwd(\""
								+ num
								+ "\",false)'>详情</a>"
								+"</div>";
						return resutsHTML;
					}
				}]],
		pagination : true,
		rownumbers : true,
		singleSelect : true,
	});
}

function downloadDCWDPdf(num){
	var obj = dcwdArray[num];
	var filename = obj.yjdc06070;
	var url = "../down_center.jsp?flag=simple/yjdc/document&filename="+filename+"";

	window.open(url);
}

function showXianqingDcwd(num){
	var obj = dcwdArray[num];
	$("#yjdc06000").attr("value",obj.yjdc06000).attr("readOnly","readOnly");
	$("#yjdc06010").attr("value",obj.yjdc06010).attr("readOnly","readOnly");
	$("#yjdc06020").attr("value",obj.yjdc06020).attr("readOnly","readOnly");
	$("#yjdc06030").attr("value",obj.yjdc06030).attr("readOnly","readOnly");
	$("#yjdc06040").attr("value",obj.yjdc06040).attr("readOnly","readOnly");
	$("#yjdc06050").attr("value",obj.yjdc06050).attr("readOnly","readOnly");
	$("#yjdc06060").attr("value",obj.yjdc06060).attr("readOnly","readOnly");
	$("#yjdc06080").attr("value",obj.yjdc06080).attr("readOnly","readOnly");
	$("#dcwdXiangqingDlg").dialog("open");
}

function dcwdQuery(){
	var sheng = $("#dcwdShen").val();
	var shi = $("#dcwdShi").val();
	var xian = $("#dcwdXian").val();
	var zhlx = $("#dcwdZHLX").val();
	var areaCode = handlerAreaFunc(shen,shi,xian);
	var zhCode = "";
	if(zhlx==""){
		zhCode = handlerZhCodeFunc(areaCode);
	}else{
		zhCode = handlerZhCodeFunc(areaCode,zhlx);
	}
	var startTime = $("#dcwdStartTime").val();
	var endTime = $("#dcwdEndTime").val();
	var url = "queryDCWD.shtml";
	var data = {
		"startTime":startTime,
		"endTime":endTime,
		"zhCode":zhCode
	};
	dcwdArray = [];
	$("#dcwdTable").datagrid({
		url : url,
		queryParams : data,
		onLoadError : function(res) {
			alert("查询失败!");
		},
		onLoadSuccess : function(res) {
		}
	});
}
